const vm = new Vue({
  el: '#app',
  data: {
    code: getUrlParam('code'),
    outmap: []
  },
  created() {
    this.init()
  },
  methods: {
    init() {
      let data = sessionStorage.getItem('outmap');
      if (data) {
        data = JSON.parse(data);
        this.outmap = this.getImgData(data);
        return
      }
      this.getDetail()
    },
    getDetail(){
      this.loading = true;
      api.requestGetXzspjPermission({
        "action": "getPermission",
        "pagemode": "serverV3P5",
        "itemCode": this.code,
      }).then((res) => {
        if(res.success){
          this.outmap = this.getImgData(res.data.outmap);
        }
      })
    },
    getImgData(data) {
      const outmap = data.map(item=>{
        let path = item.url;
        if (item.itemCode === '4742909') {
          path = '3215977'
        }
        if (item.itemCode === '4742893') {
          path = '3215119'
        }
        return{
          img: `http://hzzwfw.sd.gov.cn/hz/bsp/uploadify?action=downloadFileToServer&path=${path}&name=1.jpg&download=no`
        }
      });
      return outmap
    }
  }
});
